package com.indusfo.spc.controller;

import com.indusfo.spc.pojo.OrderTech;
import com.indusfo.spc.service.OrderTechService;
import com.indusfo.spc.vo.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author liub
 * @Date 2019/12/17 10:30
 * @Version 1.0
 */

@Controller
@RequestMapping("/service/orderTech")
public class OrderTechController {

    @Resource
    private OrderTechService orderTechService;

    /**
     * 查询
     */
    @RequestMapping(value = "/queryOrderTech")
    @ResponseBody
    public JSONObject queryOrderTech(OrderTech orderTech) {
        JSONObject json = orderTechService.queryOrderTech(orderTech);
        return json;
    }

    /**
     * 新增
     */
    @RequestMapping(value = "/insertOrderTech", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject insertOrderTech(OrderTech orderTech) {
        JSONObject json = orderTechService.insertOrderTech(orderTech);
        return json;
    }

    /**
     * 修改
     */
    @RequestMapping(value = "/updateOrderTech", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject updateOrderTech(OrderTech orderTech) {
        JSONObject json = orderTechService.updateOrderTech(orderTech);
        return json;
    }

    /**
     * 删除
     */
    @RequestMapping(value = "/deleteOrderTech", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject deleteOrderTech(@RequestParam("orderTechIds") List<Integer> orderTechIds, Integer dataState) {
        dataState = 2;
        JSONObject json = orderTechService.deleteOrderTech(orderTechIds, dataState);
        return json;
    }

    /**
     * 启停
     */
    @RequestMapping(value = "/definedOrderTech", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject definedOrderTech(@RequestParam("orderTechIds") List<Integer> orderTechIds, Integer dataState) {
        JSONObject json = orderTechService.deleteOrderTech(orderTechIds, dataState);
        return json;
    }


    /**
     * 保存工序流程
     */
    @RequestMapping(value = "/saveOrderFlow", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject saveOrderFlow(@RequestBody OrderTech orderTech) {
        JSONObject json = orderTechService.saveOrderFlow(orderTech);
        return json;
    }

    /**
     * 保存维修流程
     */
    @RequestMapping(value = "/saveOrderRepair", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject saveOrderRepair(@RequestBody OrderTech orderTech) {
        JSONObject json = orderTechService.saveOrderRepair(orderTech);
        return json;
    }
}
